package com.jason.library.common.base

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.widget.Toolbar
import com.jason.library.common.R

/**
 * @description: BaseActivity
 *
 * @author ChenBaoyang
 * @date 4/23/21 10:35
 */
abstract class BaseActivity : AppCompatActivity() {

    var toolbar: Toolbar? = null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(getLayoutId())
        parseIntent()
        beforeViewInit()
        initToolBar()
        initView()
        onDataInit()
    }

    open fun initToolBar() {
        toolbar = findViewById(R.id.toolbar)
        toolbar?.run {
            setSupportActionBar(this)
            setNavigationIcon(R.drawable.ic_back_white)
            setNavigationOnClickListener { finish() }
        }
    }

    open fun parseIntent() {

    }

    abstract fun beforeViewInit()


    abstract fun getLayoutId(): Int


    abstract fun initView()

    abstract fun onDataInit()
}